
clear all

load YR141103.txt
d= YR141103;

fname = 'YR141103';
filename=['S5467 and S5471 prelim turbidity']
legendtxt=['S5467 PS'   %core A
           'S5471 PM']  %core B




figure(1)
x=1:length(d(:,1))  %number of records
plot(d(:,6),'r-')        %turbidity from Turbidometer 1
hold on
plot(d(:,8))   %trubidity from Turbidometer 2
legend(legendtxt)             %Need to identify the cores
[AX,H1,H2] = plotyy(x,d(:,8),x,d(:,7), 'plot');   %disk rotation (RPM) from sensor 2
xlabel('record number', 'fontsize',14)
ylabel('turbidity (NTU)','fontsize',14)
set(get(AX(2),'Ylabel'),'String','disk rotation (RPM)', 'fontsize', 14)
title(filename)
print (figure(1), '-dpdf', filename)


for ii=2:length(d)
   
    
    if d(ii,6)>d(ii-1,6)*3
        d(ii,6)=d(ii-1,6);
    end
end


for ii=2:length(d)
    if d(ii,8)>d(ii-1,8)*3
        d(ii,8)=d(ii-1,8);
    end
end



figure(2)
x=1:length(d(:,1))  %number of records
plot(d(:,6),'r-')        %turbidity from Turbidometer 1
hold on
plot(d(:,8))   %trubidity from Turbidometer 2
legend(legendtxt)            %Need to identify the cores
[AX,H1,H2] = plotyy(x,d(:,8),x,d(:,7), 'plot');   %disk rotation (RPM) from sensor 2
xlabel('record number', 'fontsize',14)
ylabel('turbidity (NTU)','fontsize',14)
set(get(AX(2),'Ylabel'),'String','disk rotation (RPM)', 'fontsize', 14)
title([filename 'despiked'])

% puts the stress values where you want them

gtext({'0.01 PA'},'Fontsize',12)
gtext({'0.05 PA'},'Fontsize',12)
gtext({'0.1 PA'},'Fontsize',12)
gtext({'0.2 PA'},'Fontsize',12)
gtext({'0.3 PA'},'Fontsize',12)
gtext({'0.45 PA'},'Fontsize',12)
gtext({'0.6 PA'},'Fontsize',12)


print (figure(2), '-dpdf', [filename ' despiked'])

eval(['save ' fname '_despiked.txt d -ascii'])
